Fixed: Correct receivedQuantity calculation in getReceivedQuantityForOrderItem by including quantityRejected (OFBIZ-13429)#1322
Merged
Conversation
Contributor
|
Hi @golja Thanks for this ! Little question, quantityRejected is never empty ? This function would be simplifying like this BigDecimal getReceivedQuantityForOrderItem (GenericValue orderItem) {
return from('ShipmentReceipt')
.where(orderId: orderItem.orderId,
orderItemSeqId: orderItem.orderItemSeqId)
.queryList()
.sum { it.quantityAccepted + it.quantityRejected }
}or is quantityRejected can be empty BigDecimal getReceivedQuantityForOrderItem (GenericValue orderItem) {
return from('ShipmentReceipt')
.where(orderId: orderItem.orderId,
orderItemSeqId: orderItem.orderItemSeqId)
.queryList()
.sum { it.quantityAccepted + (it.quantityRejected ?: 0) }
} |
Contributor
Author
|
Hi @nmalin, |
…OrderItem by including quantityRejected
…null quantities Thanks to Nicolas Malin for the advice and the code snippet.
8121435 to
e99dd05
Compare
Contributor
Author
|
Hi @nmalin, Thus, I've also added a check for quantityAccepted. Thanks again, Anahita |
Contributor
|
:) you're welcome |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
As described in OFBIZ-13429, when the 'Quantity Received' value exceeds the 'Quantity' specified on a purchase order, the system automatically updates the related issuance, shipment, and order items through the updateIssuanceShipmentAndPoOnReceiveInventory shipment receipt service.
However, when one or more receipts contain rejected units, order and shipment updates fail. The issue is caused by a bug in the getReceivedQuantityForOrderItem() function, which is invoked by the updateIssuanceShipmentAndPoOnReceiveInventory service to determine the received quantity.
This PR fixes the issue by including rejected units in the quantity calculation performed by getReceivedQuantityForOrderItem(), which previously considered only accepted units and ignored rejected quantities.